-
Notifications
You must be signed in to change notification settings - Fork 5
More changes needed for NetworkX plugin #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
jim22k
commented
Oct 28, 2022
- k-truss returns a normal Graph object
- Rename convert to convert_from_nx
- Add convert_to_nx method
- Make algorithms accept Graph, Matrix, or Matrix-variant (expression, transpose, etc)
- k-truss returns a normal Graph object - Rename convert to convert_from_nx - Add convert_to_nx method - Make algorithms accept Graph, Matrix, or Matrix-variant (expression, transpose, etc)
We should probably add a utility function in
This can also have I'll give this more thought and will try to give a concrete proposal of my preference. |
Alright, here's my proposal, |
I like the |
What can we do about the return type of |
For I know the goal is to avoid translation costs when using dispatching in "real" code, so returning a I think we need to follow suit and return a dict of dicts so their code "just works". But we should also raise an issue with NetworkX and ask why that is the return type. If there is a good reason, okay keep it as is. But if not, having a Graph object feels so much more practical. |
Sorry, I misspoke. The NetworkX dict for Our native return time is naturally a Matrix; see the magic here ( graphblas-algorithms/graphblas_algorithms/algorithms/cluster.py Lines 300 to 312 in 58cdf50
So, I added a simple fix to The more I've thought about it, the more I think we should add the function dispatch name to both |
Here's another argument for adding function dispatch name to test convert functions: Some NetworkX functions/algorithms return numpy array or scipy.sparse array, but we'll want to return GraphBLAS vector or matrix. I think converting them during tests is the best option--we don't want to be forced to make our objects "look" like numpy or scipy.sparse, and it would be awkward (and difficult) to create a wrapper for them to look like numpy or scipy.sparse. |
We should use |
Codecov ReportBase: 72.80% // Head: 73.63% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #25 +/- ##
==========================================
+ Coverage 72.80% 73.63% +0.83%
==========================================
Files 68 68
Lines 2335 2348 +13
Branches 430 428 -2
==========================================
+ Hits 1700 1729 +29
+ Misses 477 459 -18
- Partials 158 160 +2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
def convert_to_nx(obj, *, name=None): | ||
from .classes import Graph | ||
|
||
if isinstance(obj, Graph): | ||
obj = obj.to_networkx() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we check isinstance(obj, Matrix)
and convert it to a scipy sparse array if scipy is installed?
We can also merge this PR and update things later.